package com.imooc.ecommerce.rocket;

import com.alibaba.fastjson.JSON;
import com.imooc.ecommerce.vo.QinyiMessage;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

/**
 * @description:
 * @author: sym
 * @create: 2021-11-30 20:36
 **/
@Component
@Slf4j
@RocketMQMessageListener(
        topic = "imooc-study-rocketmq",
        consumerGroup = "qinyi-springboot-rocketmq-string"
)
public class RocketMqConsumerString implements RocketMQListener<String> {

    @Override
    public void onMessage(String s) {
        QinyiMessage qinyiMessage = JSON.parseObject(s, QinyiMessage.class);
        log.info("consume message in RocketMQConsumerString: [{}]"
                , JSON.toJSONString(qinyiMessage));
    }
}
